{{template "header"}}

<title>分类-beego 博客</title>
</head>

<body>

<div class="navbar navbar-default navbar-fixed-top">
    <div class="container">
    {{template "navbar" .}}
    </div>

</div>

<div style="height: 50px"></div>

<div class="container">
    <div class="page-header">
        <h1>分类列表</h1>

        <form method="get" action="/category">
            <div class="form-group">
                <label for="exampleInputEmail1">分类名称</label>
                <input id="name" class="form-control" placeholder="Account" name="name">
            </div>

            <input type="hidden" name="op" value="add">
            <button type="submit" class="btn btn-default" onclick="return checkinput()">添加</button>
        </form>

        <script type="text/javascript">
            function checkinput() {
                var username = document.getElementById("name")
                if (username.value.length == 0) {
                    alert("请输入分类名称")
                    return false
                }

                return true
            }

            function backToHome() {
                window.location.href = "/";
                return false;
            }
        </script>
        <table class="table table-striped">
            <thead>
            <tr>
                <th>#</th>
                <th>名称</th>
                <th>文章数</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            {{range .Categories}}
            <tr>
            <th>{{.Id}}</th>
            <th>{{.Title}}</th>
            <th>{{.TopicCount}}</th>
            <th>
                <a href="/category?op=del&id={{.Id}}">删除</a>
            </th>
            </tr>
            {{end}}
            </tbody>
        </table>
    </div>
</div>


<script type="text/javascript" src="http://cdn.staticfile.org/jquery/3.2.1/jquery.js"></script>
<script type="text/javascript" src="/static/js/bootstrap.min.js"></script>

</body>
</html>